function [v,p_reservation,H_p_reservation]= Equilibrium_fun(v_old,p,I,cdf_p,pdf_p,g_I,...
    beta,delta,lambda,sigma,V0,C,Np,N,maxit,tol,f)
e = 1;
error = 1;

while (e <= maxit) && (error > tol)
    fprintf('ITERATION=%d \n',e);
    [pi] = pi_fun(p,I,sigma,N,f);

    [V_future] = v_future_fun(v_old, g_I);

    [W_match,p_reservation,H_p_reservation] = w_match_fun(v_old,p,pdf_p,g_I,C,Np,N,cdf_p);
     
    V0_mat = V0.*ones(Np,N);
    v = pi + beta.*delta.*(V0_mat-V_future) + beta.*lambda.*W_match + beta.*V_future;
    
    vec_v_old = v_old(:,1);
    vec_v = v(:,1);
    for i = 2:N
        vec_v_old = [vec_v_old ; v_old(:,i)];
        vec_v = [vec_v ; v(:,i)];
    end

    error = max(abs(vec_v_old-vec_v));
    v_old = v;
    e = e+1;
end

end